
define(function(){  
	var SUPPORTTOUCH = document.hasOwnProperty("ontouchstart"); 
	
	return {
		//添加cookie
		addCookie:function(objName,objValue,objHours){
			   var str = objName + "=" + escape(objValue);
			   if(objHours > 0){//为0时不设定过期时间，浏览器关闭时cookie自动消失
				    var date = new Date();
				    var ms = objHours*3600*1000;
				    date.setTime(date.getTime() + ms);
				    str += "; expires=" + date.toGMTString();
			   }
			   document.cookie = str;
			},
			
		//获取指定名称的cookie的值
		getCookie:function(objName){
				var arrStr = document.cookie.split("; ");
				for(var i = 0;i < arrStr.length;i ++){
				    var temp = arrStr[i].split("=");
				    if(temp[0] == objName) return unescape(temp[1]);
				} 
		},
		
		//为了删除指定名称的cookie，可以将其过期时间设定为一个过去的时间
		delCookie:function(name){
			   var date = new Date();
			   date.setTime(date.getTime() - 10000);
			   document.cookie = name + "=a; expires=" + date.toGMTString();
		},
		
		isTouch:SUPPORTTOUCH,
		
		/*
		 * 获取事件*/
		getEvent: SUPPORTTOUCH?["touchstart","touchend","touchmove"] : ["mousedown","mouseup","mousemove"],
				
		
		setSize:function(isFull){
			s(isFull);
			function s(isFull){
				var w = window.innerWidth;
				var h= window.innerHeight;
				var s = h/w>0.6? w/800 : h/480;
				s = s<1?1:s;
				//var sw = w/s>800?w/s:800;
				//var sh = h/s>480?h/s:480;
				var sw = 800;
				var sh = 480;
				var scene = $(".scene");
				var pokeyBox = $("#pokeyBox");
				var card =  $("#pokeyBox .card");
				if(isFull){
					scene.css({
						"-webkit-transform":"scale("+s+")",
						"display":"block",
						"width":sw,
						"height":sh
					});
					scene.attr("scale",s);
				}else{
					scene.css({
						"-webkit-transform":"scale("+s+")",
						"display":"block"
					});
					scene.attr("scale",s);
				}
				
				/*
				pokeyBox.css({
					"-webkit-transform":"scale("+(1/s)+")",
					"-webkit-transform-origin":"left",
					"width":(sw)*s+"px"
					//"bottom":-(s-1)*100/2+"px"
				});
				*/
				
			
				
				try{
					if(my && my._setPokeyMargin){
						my._setPokeyMargin();
					}
				}catch(e){}
				
			}
			
			
			
			
			
			
			var _t = this;
			
			$(window).resize(_t.throttle(function(){
				s(isFull);
			},500,1000));
			
		},
		
		/*函数节流*/
		throttle:function(fn, delay, mustRunDelay){
		    var timer = null;
		    var t_start;
		    return function(){
		        var context = this, args = arguments, t_curr = +new Date();
		        clearTimeout(timer);
		        if(!t_start){
		            t_start = t_curr;
		        }
		        if(t_curr - t_start >= mustRunDelay){
		            fn.apply(context, args);
		            t_start = t_curr;
		        }
		        else {
		            timer = setTimeout(function(){
		                fn.apply(context, args);
		            }, delay);
		        }
		    }
		 }
		
		
		



	}
}); 